package com.ymttest.business.service;

import java.io.IOException;
import java.util.List;

import org.apache.http.client.ClientProtocolException;
import org.apache.ibatis.builder.StaticSqlSource;

import com.ymatou.iapi.mqcompensate.parameter.StartBean;
import com.ymatou.iapi.mqcompensate.service.StartCall;
import com.ymatou.iapi.mqpublish.parameter.PublishBean;
import com.ymatou.iapi.mqpublish.service.PublishCall;
import com.ymttest.database.mongo.MQMessageStatusBean;
import com.ymttest.database.mongo.MQMessageStatusWapper;
import com.ymttest.utils.TestDataManager;

public class MqPublishCallService {
	
	public static PublishBean setPublishBeanForRecieveOk() throws ClientProtocolException, IOException {
		PublishBean publishBean = new PublishBean();
		PublishCall publishCall = new PublishCall();	
		
		String msguniqueid = TestDataManager.getRandomNum(10);
		String body = TestDataManager.randomStr(20);
		String appName = "testbamei";
		String codeName = "qusi";

		publishBean.setAppId(appName);
		publishBean.setCode(codeName);
		publishBean.setIp("127.0.0.1");
		publishBean.setMsgUniqueId(msguniqueid);
		publishBean.setBody(body);
		
		return publishBean;
	}
	
	public static PublishBean setPublishBeanForRecieveFail() throws ClientProtocolException, IOException {
		PublishBean publishBean = new PublishBean();
		PublishCall publishCall = new PublishCall();	
		
		String msguniqueid = TestDataManager.getRandomNum(10);
		String body = TestDataManager.randomStr(20);

		String appName = "testbamei";
		String codeName = "youqusi";		

		publishBean.setAppId(appName);
		publishBean.setCode(codeName);
		publishBean.setIp("127.0.0.1");
		publishBean.setMsgUniqueId(msguniqueid);
		publishBean.setBody(body);
		
		return publishBean;
	}
	
	public static PublishCall publishCall(PublishBean publishBean) throws ClientProtocolException, IOException {
		
		PublishCall publishCall = new PublishCall();	
		
		publishCall.setData(publishBean);
		publishCall.callService();
		
		return publishCall;
	}
}
